package com.bejoy.service.impl;

import cn.hutool.core.util.ObjectUtil;
import com.bejoy.domain.model.TUser;
import com.bejoy.mapper.TUserMapper;
import com.bejoy.service.UserService;
import jakarta.annotation.Resource;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements UserService {


    @Resource
    private TUserMapper tUserMapper;

    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {

       TUser tUser = tUserMapper.getUserByName(username);

        if (ObjectUtil.isEmpty(tUser)) {
           throw new UsernameNotFoundException("账号不存在！");
       }

        return tUser;
    }
}
